//
//  registerViewController.m
//  spotrs
//
//  Created by xu on 16/5/13.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "registerViewController.h"

@interface registerViewController ()
{
    UITextField *passName;
    UITextField *passWord;
}
@end

@implementation registerViewController

- (void)viewDidLoad {
    self.isHiddenNavagitiong = NO;
    [super viewDidLoad];
    self.navigationController.tabBarItem.title = @"注册";
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
    [tap addTarget:self action:@selector(hiddenBoard)];
    
    [self.view addGestureRecognizer:tap];
  UIView *view1 = [self creatView:@"请输入您的手机号" content:@"请输入短信验证码" fram:CGRectMake(20, 75, SCREEN_WIDTH-40, 100)button:YES];
  UIView *view2 = [self creatView:@"6-15数字和字母密码" content:@"再次输入密码" fram:CGRectMake(20, 215, SCREEN_WIDTH-40, 100)button:NO];
    
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        // 添加大小约束
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(75);
        make.right.mas_equalTo(-20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40,100 ));
        // 添加居中约束（居中方式与self相同）
       
    }];
    
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40,100 ));
        make.top.mas_equalTo(view1.mas_bottom).offset(40);
    }];
    
    UIButton *keFu = [[UIButton alloc] initWithFrame:CGRectMake(20, 185, SCREEN_WIDTH-40, 20)];
    [keFu setTitle:@"收不到短信验证码？点此电话播报" forState:UIControlStateNormal];
    [keFu setTitleColor:RGBCOLOR(248, 184, 44) forState:UIControlStateNormal];
    keFu.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:keFu];
    
    [keFu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40,20 ));
        make.top.mas_equalTo(view1.mas_bottom).offset(10);
    }];
    
    UIButton *registerBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 330, SCREEN_WIDTH-40, 40)];
    [registerBtn setBackgroundColor:RGBCOLOR(248, 184, 44)];
    [registerBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registerBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [self.view addSubview:registerBtn];
    
    [registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40,40 ));
        make.top.mas_equalTo(view2.mas_bottom).offset(15);
    }];
    
    [self creatTopNavagaiong ];
}
//生成窗口view
-(UIView*)creatView:(NSString*)title content:(NSString*)content fram:(CGRect)fram button:(BOOL)isButton
{
    UIView *backView = [[UIView alloc] initWithFrame:fram];
    [backView setBackgroundColor:RGBCOLOR(253, 254, 255)];
    backView.layer.borderWidth = 1;
    backView.layer.borderColor = RGBCOLOR(219 , 221, 221).CGColor;
    backView.layer.masksToBounds = YES;
    backView.layer.cornerRadius = 5;
    [self.view addSubview:backView];
    
    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 50, backView.frame.size.width-10, 1)];
    [lineLabel setBackgroundColor:RGBCOLOR(219 , 221, 221)];
    
    
    passName = [[UITextField alloc] initWithFrame:CGRectMake(8, 5, backView.frame.size.width-16, 40)];
    [passName setPlaceholder:title];
    [backView addSubview:passName];
    
    passWord = [[UITextField alloc] initWithFrame:CGRectMake(8, 55, backView.frame.size.width-16, 40)];
    [passWord setPlaceholder:content];
    [backView addSubview:passWord];
    [backView addSubview:lineLabel];
    
    if (isButton) {
        UIButton *recive = [[UIButton alloc]  initWithFrame:CGRectMake(backView.frame.size.width-90, backView.frame.size.height-40, 80, 30)];
        recive.titleLabel.font = [UIFont systemFontOfSize:13];
        [recive setTitle:@"获取验证码" forState:UIControlStateNormal];
        [recive setBackgroundColor:RGBCOLOR(248, 184, 44)];
        [recive addTarget:self action:@selector(reviceMessage) forControlEvents:UIControlEventTouchUpInside];
        [backView addSubview:recive];
    }
    return backView;
}
//接受短信
-(void)reviceMessage
{
    promptAlertView *prompt = [[promptAlertView alloc] initWithFrame:self.view.frame title:@"请注意查收验证码"];
    [prompt showAlert];
}
//隐藏键盘
-(void)hiddenBoard
{
    [passName resignFirstResponder];
    [passWord resignFirstResponder];
}
-(void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
